// 商品相关API
window.productAPI = {
    // 获取商品列表
    getProducts: async (params = {}) => {
        try {
            const response = await apiClient.get('/api/products/', { params });
            return response;
        } catch (error) {
            console.error('获取商品列表失败:', error);
            throw error;
        }
    },
    
    // 获取商品详情
    getProduct: async (id) => {
        try {
            const response = await apiClient.get(`/api/products/${id}`);
            return response;
        } catch (error) {
            console.error('获取商品详情失败:', error);
            throw error;
        }
    },
    
    // 创建商品
    createProduct: async (data) => {
        try {
            const response = await apiClient.post('/api/products', data);
            return response;
        } catch (error) {
            console.error('创建商品失败:', error);
            throw error;
        }
    },
    
    // 更新商品
    updateProduct: async (id, data) => {
        try {
            const response = await apiClient.put(`/api/products/${id}`, data);
            return response;
        } catch (error) {
            console.error('更新商品失败:', error);
            throw error;
        }
    },
    
    // 删除商品
    deleteProduct: async (id) => {
        try {
            const response = await apiClient.delete(`/api/products/${id}`);
            return response;
        } catch (error) {
            console.error('删除商品失败:', error);
            throw error;
        }
    },
    
    // 批量删除商品
    batchDeleteProducts: async (ids) => {
        try {
            const response = await apiClient.post('/api/products/batch-delete', { ids });
            return response;
        } catch (error) {
            console.error('批量删除商品失败:', error);
            throw error;
        }
    },
    
    // 获取分类列表
    getCategories: async () => {
        try {
            const response = await apiClient.get('/api/products/categories');
            return response;
        } catch (error) {
            console.error('获取分类列表失败:', error);
            throw error;
        }
    },
    
    // 获取供应商列表
    getSuppliers: async () => {
        try {
            const response = await apiClient.get('/api/products/suppliers');
            return response;
        } catch (error) {
            console.error('获取供应商列表失败:', error);
            throw error;
        }
    }
};
